/*
 * @Author: szx
 * @Date: 2022-01-06 13:10:32
 * @LastEditTime: 2022-01-06 13:20:01
 * @Description:
 * @FilePath: \leetcode\1-99\71\71.js
 */
/**
 * @param {string} path
 * @return {string}
 */
var simplifyPath = function (path) {
    const names = path.split('/');
    console.log(names);
    const stack = [];
    for (const name of names) {
        if (name === '..') {
            if (stack.length) {
                stack.pop();
            }
        } else if (name.length && name !== '.') {
            stack.push(name);
        }
    }
    return '/' + stack.join('/');
};
